<?php
namespace app\wechat\controller;

use app\BaseController;
use EasyWeChat\Factory;
use app\common\model\Wechat as WechatModel;
use helper\Wechat as WechatClass;
use helper\Logdriver;

class RelateServer extends BaseController
{
	protected $app;
	protected $Wechat;
	public function __construct()
    {
        $this->Wechat = new WechatClass(request()->domain());
        $this->app = Factory::officialAccount($this->Wechat->get_config());
    }

    public function relateWeixin()
    {
    	// 校验开发者微信服务器
        
        $this->app->server->push(function ($message) {
            $msgInfo = $this->Wechat->messageHandler($message);
            return $msgInfo;
        });
        $response = $this->app->server->serve();
        
        return $response->send();
    }
    /**
     * 校验开发者服务器
     */
    private function ckServer()
    {
        $response = $this->app->server->serve();
        return $response->send();
    }
    
}
